/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
//作者:AKPower
//算法:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef int ll;
const ll mod = 1e9 + 7;
const ll maxn = 1e6 + 100;
ll dp[maxn][20];

int main()
{
    IOS;
    ll n;
    cin >> n;
    dp[0][0] = 1;
    dp[1][0] = 1;
    dp[1][1] = 1;
    for (ll i = 2; i <= n; i++)
    {
        for (ll j = 0; i - (1ll << j) >= 0; j++)
        {
            if ((1ll << j) == i)
            {
                dp[i][j] = 1;
                continue;
            }
            ll num = i - (1ll << j);
            if ((1ll << j) <= num)
            {
                for (ll k = 0; k <= j; k++)
                    dp[i][j] = (dp[num][k] + dp[i][j]) % mod;
            }
            else
            {
                ll h = (ll)log2(num);
                for (ll k = 0; k <= h; k++)
                    dp[i][j] = (dp[num][k] + dp[i][j]) % mod;
            }
            // cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    ll ans = 0;
    for (ll i = 0; (1ll << i) <= n; i++)
    {
        ans = (ans + dp[n][i]) % mod;
    }
    cout << ans << endl;
    getchar();
    getchar();
    return 0;
}
